<?php
namespace Home\Controller;
use Think\Controller;
class OrginizationController extends Controller
{
    public function orginization(){
        $this->display();
        
    }
    public function toStart(){
        redirect('Start/start');
    }
    public function insertOrginization(){
        //echo "insertOrginization()";
        $data['schoolname'] =$_POST['schoolname'];
        $data['area'] =$_POST['area'];
        $data['manageNum'] =$_POST['manageNum'];
        $data['teacherNum']=$_POST['teacherNum'];
        $this->addDate($data,'school');
       return $this->display('Orginization/orginization');
    }
    
    public function entrepreneurship(){
       echo $data['name']=$_POST['adminName'];
       echo $data['duty']=$_POST['duties'];
       echo $data['id']=$_POST['jobnumber'];
        //$data['name ']=$_POST['adminName'];
       // $data['name ']=$_POST['adminName'];
       echo $this->addDate($data,'teacherinfo');
        $this->display('Orginization/orginization');
    }
    
    
    public function addDate($data,$table){
       
        $Orgininfo=M($table);
        $Ret = -1;
        try {
            $Ret =$Orgininfo->add($data);
            echo "成功！";
        } catch (\Exception $e) {
            if ($e->getCode()==23000){
                echo "插入数据为Unique导致失败！";
                die();
            }
            echo "失败！";
        }
        
    }
}

